import { Form, Input, Button} from 'antd'
const Filter =  (props) => {
  const FormItem = Form.Item
  let formData = props.formData
  let changeValue = (event) => {
    props.changeState(event.target.name, event.target.value)
  }
  const listData = formData.map((item, index) => {
   return (
    <FormItem key={index} label={item.title} >
      <Input name={item.value} onChange={changeValue}/>
    </FormItem>
   )
  })
  const alertData = () => {
    let data = {}
    for (let item in props.data) {
      if (item !== 'formData') {
        data[item] = props.data[item]
      }
    }
    alert(JSON.stringify(data))
  }
  return(
    <Form>
      {listData}
      <Button type='success' onClick={alertData}>保存</Button>
    </Form>
  )
}

export default Form.create()(Filter)